package LinkedListStack;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.List;

import static org.junit.jupiter.api.Assertions.*;

public class LinkedListStackTest {
    LinkedListStack<Object> stack = new LinkedListStack<>(3);
    @Test
    void push() {
        stack.push(1);
        stack.push(2);
        stack.push(3);
        assertFalse(stack.push(4));
        assertIterableEquals(List.of(3,2,1),stack);
    }

    @Test
    void pop() {
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.pop();
        assertIterableEquals(List.of(2,1),stack);
        stack.pop();
        assertIterableEquals(List.of(1),stack);
        stack.pop();
        stack.pop();

        // 断言堆栈现在是空的
        assertTrue(stack.isEmpty(), "Stack should be empty after popping all elements");
    }

    @Test
    void peek() {
        stack.push(1);
        stack.push(2);
        stack.push(3);
        assertEquals(3,stack.peek());
    }
}
